package com.itheima.controller;

import com.itheima.entity.Result;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Component
public class ExceptionAdvice {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result doBusinessException(Exception ex) {

        ex.printStackTrace();

        return new Result(false, ex.getMessage());
    }
}
